package cn.jee.entity;

import jakarta.persistence.*;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@Entity
@NoArgsConstructor
public class Stu2 {
  @Id
  private Long id;
  @NotBlank
  @Size(min=2,max=6)//message = "{name.size.error}"
  private String name;
  @DecimalMin(value = "12",inclusive = false)//>12
  private double java;
  @DecimalMax("100")
  private double math;
  @Min(value = 18)//message = "{age.outof.range}"
  int age;
  @ManyToOne
  @JoinColumn(name = "address_id")
  @Valid
  Address address;

  public Stu2( String name, double java, double math, int age) {
    this.name = name;
    this.java = java;
    this.math = math;
    this.age = age;
  }
}